//
//  CXYSongMenuCollectionViewCell.m
//  NewMusic
//
//  Created by chuxinyu123 on 15/11/14.
//  Copyright © 2015年 Going. All rights reserved.
//

#import "CXYSongMenuCollectionViewCell.h"
#import <UIImageView+WebCache.h>
#import <SDWebImageManager.h>

@implementation CXYSongMenuCollectionViewCell

- (void)dealloc
{
    [_titleLabel release];
    [_tableBackView release];
    [_mainImageView release];
    [_listenImageView release];
    [super dealloc];
}
- (instancetype)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self) {
        [self buildCXYCollectionCell];
    }
    return self;
}

- (void)buildCXYCollectionCell
{
    self.mainImageView = [[UIImageView alloc] init];
    self.listenImageView = [[UIImageView alloc] init];
    self.titleLabel = [[UILabel alloc] init];
    self.titleLabel.backgroundColor = [UIColor clearColor];
    self.titleLabel.textColor = [UIColor colorWithRed:180 / 255.0 green:180 / 255.0 blue:180 / 255.0 alpha:1.0];
    self.titleLabel.font = [UIFont systemFontOfSize:13];
    self.tableBackView = [[UIView alloc] init];
    self.tableBackView.backgroundColor = [UIColor whiteColor];
    self.tableBackView.alpha = 0.05;
    
    [self.contentView addSubview:_tableBackView];
    [self.contentView addSubview:_mainImageView];
    [self.contentView addSubview:_listenImageView];
    [self.contentView addSubview:_titleLabel];
    
    
    [_mainImageView release];
    [_listenImageView release];
    [_titleLabel release];
    [_tableBackView release];
}

- (void)layoutSubviews
{
    [super layoutSubviews];
    _tableBackView.frame = CGRectMake(0, 0, self.frame.size.width, self.frame.size.height);
    _mainImageView.frame = CGRectMake(0, 0, self.frame.size.width, self.frame.size.width);
    _titleLabel.frame = CGRectMake(0, _mainImageView.frame.size.height, self.frame.size.width, 30);
}

- (void)setSongMenuModel:(SongMenuModel *)songMenuModel
{
    if (_songMenuModel != songMenuModel) {
        [_songMenuModel release];
        _songMenuModel = [songMenuModel retain];
    }
    _titleLabel.text = songMenuModel.title;
    [_mainImageView sd_setImageWithURL:[NSURL URLWithString:songMenuModel.pic_url]];
    _tableBackView.backgroundColor = [UIColor whiteColor];
}

@end
